<!DOCTYPE html>
<html lang="en-US">
    <head>
        <title>Plack::Middleware::TemplateToolkit - serve a pages via Template Toolkit - metacpan.org</title>
        <link rel="preload" as="fetch" href="https://metacpan.org/account/login_status" crossorigin="anonymous" />
        <link href="https://metacpan.org/_assets/b8ccceeed47a0652049703d99326a9cea4933443.css" rel="stylesheet" type="text/css">
        <script src="https://metacpan.org/_assets/6bfedafe2d7caa915b7d84f61b45936818e3242e.js" type="text/javascript" defer></script>
        <link rel="alternate" type="application/rss+xml" title="Recent CPAN Uploads of Plack-Middleware-TemplateToolkit - MetaCPAN" href="https://metacpan.org/dist/Plack-Middleware-TemplateToolkit/releases.rss" />
        <link rel="canonical" href="./Plack::Middleware::TemplateToolkit.html" />
        <meta name="description" content="serve a pages via Template Toolkit" />
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5">
        <link rel="shortcut icon" href="https://metacpan.org/static/icons/favicon.ico">
        <link rel="apple-touch-icon" sizes="152x152" href="https://metacpan.org/static/icons/apple-touch-icon.png">
        <link rel="search" href="https://metacpan.org/static/opensearch.xml" type="application/opensearchdescription+xml" title="MetaCPAN">
        <script>
          (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
          (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
          })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

          (function(skey, ga_id){
            ga('create', ga_id, {
              siteSpeedSampleRate : 100,
              storage             : 'none',
              clientId            : localStorage.getItem(skey)
            });
            ga(function(tracker) {
              localStorage.setItem(skey, tracker.get('clientId'));
            });
            ga('send', 'pageview');
          })('ga:clientId', 'UA-27829474-1');
        </script>
<meta name="twitter:card"        content="summary" />
<meta name="twitter:url"         content="https://metacpan.org/pod/Plack::Middleware::TemplateToolkit" />
<meta name="twitter:title"       content="Plack::Middleware::TemplateToolkit" />
<meta name="twitter:description" content="serve a pages via Template Toolkit" />
<meta name="twitter:site"        content="metacpan" />
    </head>
    <body>
        <nav class="navbar navbar-default" role="navigation">
            <div class="header-logo-large hidden-xs">
              <a href="https://metacpan.org/" tabindex="0">
                <svg class="logo" aria-label="MetaCPAN">
                  <use class="logo" href="/static/images/metacpan-logo.svg#logo" />
                </svg>
              </a>
            </div>
            <div class="header-logo-icon visible-xs">
              <a href="https://metacpan.org/">
                <svg class="logo" aria-label="MetaCPAN">
                  <use class="logo" href="/static/images/metacpan-logo.svg#dots" />
                </svg>
              </a>
            </div>
            <ul class="nav navbar-nav menu-items hidden-xs hidden-sm">
              <li><a href="https://metacpan.org/about">About</a></li>
              <li><a href="https://metacpan.org/about/sponsors">Sponsor</a></li>
              <li><a href="https://grep.metacpan.org/">grep::cpan</a></li>
              <li><a href="https://metacpan.org/recent">Recent</a></li>
              <li><a href="https://metacpan.org/about/faq">FAQ</a></li>
              <li><a href="https://metacpan.org/tools">Tools</a></li>
              <li><a href="https://fastapi.metacpan.org/">API</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <button type="button" class="searchbar-btn visible-xs visible-sm">
                    <i class="fa fa-search button-fa-icon"></i>
                </button>
                <form action="https://metacpan.org/search" class="searchbar-form visible-md visible-lg search-form form-horizontal">
                   <input type="hidden" name="size" id="metacpan_search-size" value="20">
                  <div class="form-group">
                      <div class="search-group">
                        <i class="fa fa-search"></i>
                        <input type="text" name="q" placeholder="Search the CPAN" size="41" autocorrect="off" autocapitalize="off" spellcheck="false" id="metacpan_search-input" class="form-control" value="">
                      </div>
                  </div>
                </form>
                    <li class="icon-slidepanel visible-xs visible-sm">
                      <button data-toggle="slidepanel" data-target=".slidepanel">
                        <span class="button-fa-icon">
                          <i class="fa fa-bars slidepanel-open"></i>
                          <i class="fa fa-times slidepanel-close"></i>
                        </span>
                      </button>
                    </li>
                <form action="https://metacpan.org/account/logout" method="POST" id="metacpan-logout"></form>
                <li class="dropdown logged_in" style="display: none;">
                    <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                      <i class="fa fa-user button-fa-icon logged-in-icon" aria-hidden="true"></i>
                      <i class="fas fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu">
                        <li><a href="https://metacpan.org/account/identities">Identities</a></li>
                        <li><a href="https://metacpan.org/account/profile">Profile</a></li>
                        <li><a href="https://metacpan.org/account/favorite/list">Favorites</a></li>
                        <li>
                            <a href="./Plack::Middleware::TemplateToolkit.html#" type="button" onclick="$('#metacpan-logout').submit(); return false">
                              Logout
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown logged_out" style="display: none;">
                    <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                      <i class="fa fa-user button-fa-icon" aria-hidden="true"></i>
                      <i class="fas fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu">
                        <li>
                            <a href="https://metacpan.org/login/github">
                                <i class="fab fa-github fa-fw"></i>
                                GitHub
                            </a>
                        </li>
                        <li>
                            <a href="https://metacpan.org/login/twitter">
                                <i class="fab fa-twitter fa-fw"></i>
                                Twitter
                            </a>
                        </li>
                        <li>
                            <a href="https://metacpan.org/login/google">
                                <i class="fab fa-google fa-fw"></i>
                                Google
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown logged_placeholder">
                    <button>
                      <i class="fa fa-user button-fa-icon" aria-hidden="true"></i>
                    </button>
                </li>
            </ul>
        </nav>
        <div class="page-content ">
          <!--
          <div class="top-notify-banner">
            <i class="fas fa-info-circle"></i>
          </div>
          -->
          <nav class="sidebar">
            <div class="slidepanel">
              <ul class="nav-list ">
    <li class="nav-header no-margin-top">
      <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The date that this version of Plack-Middleware-TemplateToolkit was released.">
      <span class="relatize">16 Feb 2015 19:02:22 UTC</span>
    </li>
  <li>
    Distribution: <a href="https://metacpan.org/dist/Plack-Middleware-TemplateToolkit">Plack-Middleware-TemplateToolkit</a>
  </li>
  <li>
    Module version: 0.28
  </li>
  <li>
    <a data-keyboard-shortcut="g s" href="https://metacpan.org/dist/Plack-Middleware-TemplateToolkit/source/lib/Plack/Middleware/TemplateToolkit.pm">Source</a>
    (<a href="https://metacpan.org/dist/Plack-Middleware-TemplateToolkit/source/lib/Plack/Middleware/TemplateToolkit.pm?raw=1">raw</a>)
  </li>
  <li>
    <a data-keyboard-shortcut="g b" href="https://metacpan.org/dist/Plack-Middleware-TemplateToolkit/source/lib/Plack/Middleware">Browse</a>
    (<a href="https://metacpan.org/dist/Plack-Middleware-TemplateToolkit/source/lib/Plack/Middleware?raw=1">raw</a>)
  </li>
    <li>
      <a data-keyboard-shortcut="g c" href="https://metacpan.org/dist/Plack-Middleware-TemplateToolkit/changes">Changes</a>
    </li>
    <li>
      <a class="nopopup" href="https://metacpan.org/dist/Plack-Middleware-TemplateToolkit/contribute">How to Contribute</a>
    </li>
    <li>
        <a rel="noopener nofollow" data-keyboard-shortcut="g r" href="https://github.com/ranguard/Plack-Middleware-TemplateToolkit">Repository</a>
    </li>
    <li>
      <a rel="noopener nofollow" data-keyboard-shortcut="g i" href="https://github.com/ranguard/Plack-Middleware-TemplateToolkit/issues">Issues</a>
      (0)
    </li>
    <li>
      <a rel="noopener nofollow" href="http://matrix.cpantesters.org/?dist=Plack-Middleware-TemplateToolkit+0.28" title="Matrix">Testers</a>
        <span title="(pass / fail / na)">(<a rel="noopener nofollow" href="https://www.cpantesters.org/distro/P/Plack-Middleware-TemplateToolkit.html?oncpan=1&amp;distmat=1&amp;version=0.28&amp;grade=2" style="color: #090">23</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/P/Plack-Middleware-TemplateToolkit.html?oncpan=1&amp;distmat=1&amp;version=0.28&amp;grade=3" style="color: #900">0</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/P/Plack-Middleware-TemplateToolkit.html?oncpan=1&amp;distmat=1&amp;version=0.28&amp;grade=4">0</a>)</span>
    </li>
    <li>
      <a rel="noopener nofollow" href="http://cpants.cpanauthors.org/release/LLAP/Plack-Middleware-TemplateToolkit-0.28">Kwalitee</a>
    </li>
    <li>
      <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The # people with an indexing permission on Plack-Middleware-TemplateToolkit who have released something to CPAN in the last 2 years (i.e. the # people likely able to release critical fixes in a timely manner)">
      Bus factor: 0
      </div>
    </li>
    <li>
      <a rel="noopener nofollow" href="http://cpancover.com/latest/Plack-Middleware-TemplateToolkit-0.28/index.html">88.81% Coverage </a>
    </li>
    <li>
      License: perl_5
    </li>
    <li>
      Perl: v5.8.1
    </li>
    <li class="nav-header">Activity</li>
    <li>
<div class="activity-graph">
    <img src="https://metacpan.org/dist/Plack-Middleware-TemplateToolkit/activity.svg?res=month" />
    <div class="comment">24 month</div>
</div>
    </li>
    <li class="nav-header">Tools</li>
    <li>
      <a itemprop="downloadUrl" href="https://cpan.metacpan.org/authors/id/L/LL/LLAP/Plack-Middleware-TemplateToolkit-0.28.tar.gz">
      Download (<span itemprop="fileSize">22.74KB</span>)</a>
    </li>
    <li>
      <a href="https://explorer.metacpan.org/?url=%2Fmodule%2FLLAP%2FPlack-Middleware-TemplateToolkit-0.28%2Flib%2FPlack%2FMiddleware%2FTemplateToolkit.pm">
        MetaCPAN Explorer
      </a>
    </li>
    <li>
      <a href="https://metacpan.org/dist/Plack-Middleware-TemplateToolkit/permissions">
        Permissions
      </a>
    </li>
    <li>
      <a href="https://metacpan.org/dist/Plack-Middleware-TemplateToolkit/releases.rss">
        Subscribe to distribution
      </a>
    </li>
    <li>
      <button class="btn btn-link" data-toggle="modal" data-target="#metacpan_install-instructions-dialog">
        Install Instructions
      </button>
    </li>
    <li>
      <form action="https://metacpan.org/search">
        <input type="hidden" name="q" value="dist:Plack-Middleware-TemplateToolkit">
        <input type="search" name="q" placeholder="Search distribution" class="form-control tool-bar-form">
        <input type="submit" style="display: none">
      </form>
    </li>
    <li>
      <form action="https://grep.metacpan.org/search">
        <input type="hidden" name="qd" value="Plack-Middleware-TemplateToolkit">
        <input type="hidden" name="source" value="metacpan">
        <input type="search" name="q" placeholder="grep distribution" class="form-control tool-bar-form">
        <input type="submit" style="display: none">
     </form>
    </li>
    <li class="version-jump">
<select onchange="document.location.href=&#39;/release/&#39;+this.value+&#39;/view/lib/Plack/Middleware/TemplateToolkit.pm&#39;" class="form-control tool-bar-form">
  <option disabled selected>Jump to version</option>
<option
  disabled
  value="LLAP/Plack-Middleware-TemplateToolkit-0.28"
>0.28
  (LLAP on 2015-02-16)</option>
<optgroup label="BackPAN">'
<option
  
  value="LLAP/Plack-Middleware-TemplateToolkit-0.27"
>0.27
  (LLAP on 2014-03-08)</option>
<option
  
  value="LLAP/Plack-Middleware-TemplateToolkit-0.26"
>0.26
  (LLAP on 2012-09-29)</option>
<option
  
  value="LLAP/Plack-Middleware-TemplateToolkit-0.25"
>0.25
  (LLAP on 2011-11-09)</option>
<option
  
  value="LLAP/Plack-Middleware-TemplateToolkit-0.2"
>0.2
  (LLAP on 2011-07-17)</option>
<option
  
  value="LLAP/Plack-Middleware-TemplateToolkit-0.15"
>0.15
  (LLAP on 2011-06-28)</option>
<option
  
  value="LLAP/Plack-Middleware-TemplateToolkit-0.1"
>0.1
  (LLAP on 2011-06-01)</option>
</optgroup>
</select>
    </li>
    <li class="version-diff">
<select onchange="document.location.href='/release/LLAP/Plack-Middleware-TemplateToolkit-0.28/diff/' + encodeURIComponent(this.value) + '/lib/Plack/Middleware/TemplateToolkit.pm'
" class="form-control tool-bar-form">
  <option disabled selected>Diff with version</option>
<option
  disabled
  value="LLAP/Plack-Middleware-TemplateToolkit-0.28"
>0.28
  (LLAP on 2015-02-16)</option>
<optgroup label="BackPAN">'
<option
  
  value="LLAP/Plack-Middleware-TemplateToolkit-0.27"
>0.27
  (LLAP on 2014-03-08)</option>
<option
  
  value="LLAP/Plack-Middleware-TemplateToolkit-0.26"
>0.26
  (LLAP on 2012-09-29)</option>
<option
  
  value="LLAP/Plack-Middleware-TemplateToolkit-0.25"
>0.25
  (LLAP on 2011-11-09)</option>
<option
  
  value="LLAP/Plack-Middleware-TemplateToolkit-0.2"
>0.2
  (LLAP on 2011-07-17)</option>
<option
  
  value="LLAP/Plack-Middleware-TemplateToolkit-0.15"
>0.15
  (LLAP on 2011-06-28)</option>
<option
  
  value="LLAP/Plack-Middleware-TemplateToolkit-0.1"
>0.1
  (LLAP on 2011-06-01)</option>
</optgroup>
</select>
    </li>

    <li>
<ul class="dependencies">
  <li class="nav-header">Dependencies</li>
  <li><a href="https://metacpan.org/pod/Carp" title="Carp" class="ellipsis">Carp</a></li>
  <li><a href="https://metacpan.org/pod/Encode" title="Encode" class="ellipsis">Encode</a></li>
  <li><a href="https://metacpan.org/pod/Exporter" title="Exporter" class="ellipsis">Exporter</a></li>
  <li><a href="https://metacpan.org/pod/HTTP::Status" title="HTTP::Status" class="ellipsis">HTTP::Status</a></li>
  <li><a href="https://metacpan.org/pod/Plack::MIME" title="Plack::MIME" class="ellipsis">Plack::MIME</a></li>
  <li><a href="https://metacpan.org/pod/Plack::Middleware" title="Plack::Middleware" class="ellipsis">Plack::Middleware</a></li>
  <li><a href="https://metacpan.org/pod/Plack::Middleware::Debug::Base" title="Plack::Middleware::Debug::Base" class="ellipsis">Plack::Middleware::Debug::Base</a></li>
  <li><a href="https://metacpan.org/pod/Plack::Middleware::Debug::Timer" title="Plack::Middleware::Debug::Timer" class="ellipsis">Plack::Middleware::Debug::Timer</a></li>
  <li><a href="https://metacpan.org/pod/Plack::Request" title="Plack::Request" class="ellipsis">Plack::Request</a></li>
  <li><a href="https://metacpan.org/pod/Plack::Util::Accessor" title="Plack::Util::Accessor" class="ellipsis">Plack::Util::Accessor</a></li>
  <li><a href="https://metacpan.org/pod/Scalar::Util" title="Scalar::Util" class="ellipsis">Scalar::Util</a></li>
  <li><a href="Template.html" title="Template" class="ellipsis">Template</a></li>
  <li><a href="https://metacpan.org/pod/Time::HiRes" title="Time::HiRes" class="ellipsis">Time::HiRes</a></li>
  <li><a href="https://metacpan.org/pod/parent" title="parent" class="ellipsis">parent</a></li>
  <li><a href="https://metacpan.org/pod/strict" title="strict" class="ellipsis">strict</a></li>
  <li><a href="https://metacpan.org/pod/warnings" title="warnings" class="ellipsis">warnings</a></li>
  <li>
    <hr>
  </li>
  <li>
    <a href="https://metacpan.org/module/Plack::Middleware::TemplateToolkit/requires">Reverse dependencies</a>
  </li>
  <li>
    <a href="http://deps.cpantesters.org/?module=Plack%3A%3AMiddleware%3A%3ATemplateToolkit">CPAN Testers List</a>
  </li>
  <li>
    <a href="https://cpandeps.grinnz.com/?dist=Plack-Middleware-TemplateToolkit">Dependency graph</a>
  </li>
</ul>
    </li>
    <li class="nav-header">Permalinks</li>
    <li>
      <a href="https://metacpan.org/release/LLAP/Plack-Middleware-TemplateToolkit-0.28/view/lib/Plack/Middleware/TemplateToolkit.pm">This version</a>
    </li>
    <li>
      <a href="./Plack::Middleware::TemplateToolkit.html">Latest version</a>
    </li>
    <li>
<div class="plussers">
<div class="nav-header">++ed by:</div>
<div>
<a class="display-all" href="https://metacpan.org/author/VOJ"><img src="https://www.gravatar.com/avatar/dcad11c6680a6c59cc31d2bf1b3975e5?d=identicon&amp;s=20" title="VOJ" alt="VOJ"></a>
<a class="display-all" href="https://metacpan.org/author/LLAP"><img src="https://www.gravatar.com/avatar/fe83c062043dc4e41c9af07b080e306e?d=identicon&amp;s=20" title="LLAP" alt="LLAP"></a>
<a class="display-all" href="https://metacpan.org/author/ABRAXXA"><img src="https://www.gravatar.com/avatar/b2dd4ce034bcb23b757d22d2061cb10d?d=identicon&amp;s=20" title="ABRAXXA" alt="ABRAXXA"></a>
<a class="display-all" href="https://metacpan.org/author/MJEMMESON"><img src="https://www.gravatar.com/avatar/e17c4cf81cbd75b5043884252c378c47?d=identicon&amp;s=20" title="MJEMMESON" alt="MJEMMESON"></a>
</div>
<!-- Display counts of plussers-->
<div>
    <a href="https://metacpan.org/dist/Plack-Middleware-TemplateToolkit/plussers">4 PAUSE users</a>
</div>
</div>
    </li>
    <li>
<div id="metacpan_contributors">
  <div>
    <button class="btn-link"
      onclick="$(this).hide(); $('#metacpan_contributors ul').slideDown(); return false;"
    >and 2 contributors</button>
  </div>
  <ul style="display: none">
    <li class="contributor"
    >
      Leo Lapworth
    </li>
    <li class="contributor"
    >
      Jakob Voss
    </li>
  </ul>
</div>
    </li>
              </ul>
            </div>
          </nav>
          <div class="content-navigation">
<div class="breadcrumbs">
  <span>
    <a data-keyboard-shortcut="g a" rel="author" href="https://metacpan.org/author/LLAP" class="author-name">Leo Lapworth</a>
  </span>
  <span>&nbsp;/&nbsp;</span>
  <div class="release dist-release status-latest maturity-released">
    <span class="dropdown"><b class="caret"></b></span>
<select onchange="document.location.href=&#39;/release/&#39;+this.value+&#39;/view/lib/Plack/Middleware/TemplateToolkit.pm&#39;" class="">
<option
  selected
  value="LLAP/Plack-Middleware-TemplateToolkit-0.28"
>0.28
  (LLAP on 2015-02-16)</option>
<optgroup label="BackPAN">'
<option
  
  value="LLAP/Plack-Middleware-TemplateToolkit-0.27"
>0.27
  (LLAP on 2014-03-08)</option>
<option
  
  value="LLAP/Plack-Middleware-TemplateToolkit-0.26"
>0.26
  (LLAP on 2012-09-29)</option>
<option
  
  value="LLAP/Plack-Middleware-TemplateToolkit-0.25"
>0.25
  (LLAP on 2011-11-09)</option>
<option
  
  value="LLAP/Plack-Middleware-TemplateToolkit-0.2"
>0.2
  (LLAP on 2011-07-17)</option>
<option
  
  value="LLAP/Plack-Middleware-TemplateToolkit-0.15"
>0.15
  (LLAP on 2011-06-28)</option>
<option
  
  value="LLAP/Plack-Middleware-TemplateToolkit-0.1"
>0.1
  (LLAP on 2011-06-01)</option>
</optgroup>
</select>
    <a data-keyboard-shortcut="g d" class="release-name" href="https://metacpan.org/dist/Plack-Middleware-TemplateToolkit">Plack-Middleware-TemplateToolkit-0.28</a>
  </div>
<span class="river-gauge-gauge">
  <svg width="24px"
       height="15px"
       version="1.1"
       xmlns="http://www.w3.org/2000/svg"
       xmlns:xlink="http://www.w3.org/1999/xlink">

    <g>
      <title>        River stage one &#10;
          • 1 direct dependent &#10;          • 1 total dependent
      </title>

      <rect x="0"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="5"  y="0" width="4" height="15" fill="#e4e2e2" />
      <rect x="10"  y="0" width="4" height="15" fill="#e4e2e2" />
      <rect x="15"  y="0" width="4" height="15" fill="#e4e2e2" />
      <rect x="20"  y="0" width="4" height="15" fill="#e4e2e2" />
    </g>
  </svg>

</span>
<div id="Plack-Middleware-TemplateToolkit-fav" class="logged_in">
<form action="https://metacpan.org/account/favorite/add" style="display: inline" onsubmit="return favDistribution(this)">
    <input type="hidden" name="remove" value="0">
    <input type="hidden" name="release" value="Plack-Middleware-TemplateToolkit-0.28">
    <input type="hidden" name="author" value="LLAP">
    <input type="hidden" name="distribution" value="Plack-Middleware-TemplateToolkit">
    <button type="submit" class="favorite highlight"><span>4</span> ++</button>
</form>
</div>
<div class="logged_out">
<a href="./Plack::Middleware::TemplateToolkit.html" onclick="alert('Please sign in to add favorites'); return false" class="favorite highlight">
<span>4</span> ++</a>
</div>
   / <span>Plack::Middleware::TemplateToolkit</span>
</div>
          </div>
          <main class="content">


<nav class="toc">
  <div class="toc-header"><strong>Contents</strong></div>
<ul>
  <li><a href="./Plack::Middleware::TemplateToolkit.html#NAME">NAME</a></li>
  <li><a href="./Plack::Middleware::TemplateToolkit.html#SYNOPSIS">SYNOPSIS</a></li>
  <li><a href="./Plack::Middleware::TemplateToolkit.html#DESCRIPTION">DESCRIPTION</a></li>
  <li><a href="./Plack::Middleware::TemplateToolkit.html#CONFIGURATIONS">CONFIGURATIONS</a></li>
  <li><a href="./Plack::Middleware::TemplateToolkit.html#ENVIRONMENT">ENVIRONMENT</a></li>
  <li><a href="./Plack::Middleware::TemplateToolkit.html#METHODS">METHODS</a>
    <ul>
      <li><a href="./Plack::Middleware::TemplateToolkit.html#process_template-(-$template,-$code,-%5C%25vars-)">process_template ( $template, $code, \%vars )</a></li>
      <li><a href="./Plack::Middleware::TemplateToolkit.html#process_error-(-$code,-$error,-$type,-$req-)-=-@_;">process_error ( $code, $error, $type, $req ) = @_;</a></li>
    </ul>
  </li>
  <li><a href="./Plack::Middleware::TemplateToolkit.html#SEE-ALSO">SEE ALSO</a></li>
  <li><a href="./Plack::Middleware::TemplateToolkit.html#AUTHORS">AUTHORS</a></li>
</ul></nav>
<div class="pod anchors">
<h1 id="NAME">NAME</h1>

<pre><code>    Plack::Middleware::TemplateToolkit - serve a pages via Template Toolkit</code></pre>

<h1 id="SYNOPSIS">SYNOPSIS</h1>

<pre><code>    use Plack::Builder;

    my $root = &#39;/path/to/html_doc_root&#39;;

    builder {

        # Page to show when requested file is missing
        enable &#39;ErrorDocument&#39;,    #
            404 =&gt; &quot;$root/page_not_found.html&quot;;

        # These files can be served directly
        enable &#39;Static&#39;,
            path =&gt; qr{\.(gif|png|jpg|swf|ico|mov|mp3|pdf|js|css)$},
            root =&gt; $root;

        enable &#39;TemplateToolkit&#39;,
            INCLUDE_PATH =&gt; $root,    # required
            pass_through =&gt; 1;        # delegate missing templates to $app

        $app;
    }</code></pre>

<p>A minimal <a href="PSGI.html">.psgi</a> script as stand-alone application:</p>

<pre><code>    use Plack::Middleware::TemplateToolkit;
    Plack::Middleware::TemplateToolkit-&gt;new( INCLUDE_PATH =&gt; &quot;/path/to/docs&quot; );</code></pre>

<h1 id="DESCRIPTION">DESCRIPTION</h1>

<p>Enable this middleware or application to allow your Plack-based application to serve files processed through <a href="Template.html">Template Toolkit</a> (TT). The idea behind this module is to provide content that is ALMOST static, but where having the power of TT can make the content easier to manage. You probably only want to use this for the simplest of sites, but it should be easy enough to migrate to something more significant later.</p>

<p>As <a href="https://metacpan.org/pod/Plack::Middleware">Plack::Middleware</a> derives from <a href="https://metacpan.org/pod/Plack::Component">Plack::Component</a> you can also use this as simple application. If you just want to serve files via Template Toolkit, treat this module as if it was called Plack::App::TemplateToolkit.</p>

<p>You can mix this middleware with other Plack::App applications and Plack::Middleware which you will find on CPAN.</p>

<p>This middleware reads and sets the PSGI environment variable <code>tt.vars</code> for variables passed to templates. By default, the QUERY_STRING params are available to the templates, but the more you use these the harder it could be to migrate later so you might want to look at a propper framework such as <a href="Catalyst.html">Catalyst</a> if you do want to use them:</p>

<pre><code>  [% params.get(&#39;field&#39;) %] params is a L&lt;Hash::MultiValue&gt;
  [% request.parameters.field %] configured with request_vars =&gt; [&#39;parameters&#39;]</code></pre>

<p>A full example application is included in this module in the exmple directory.</p>

<h1 id="CONFIGURATIONS">CONFIGURATIONS</h1>

<p>You can use all configuration options that are supported by Template Toolkit (INCLUDE_PATH, INTERPOLATE, POST_COMP...). See <a href="https://metacpan.org/pod/Template::Manual::Config">Template::Manual::Config</a> for an overview. The only mandatory option is INCLUDE_PATH to point to where the templates live.</p>

<dl>

<dt id="path">path</dt>
<dd>

<p>Specifies an URL pattern or a callback to match with requests to serve templates for. See <a href="https://metacpan.org/pod/Plack::Middleware::Static">Plack::Middleware::Static</a> for further description. Unlike Plack::Middleware::Static this middleware uses <code>&#39;/&#39;</code> as default path. You may also consider using <a href="https://metacpan.org/pod/Plack::App::URLMap">Plack::App::URLMap</a> and the <code>mount</code> syntax from <a href="https://metacpan.org/pod/Plack::Builder">Plack::Builder</a> to map requests based on a path to this middleware.</p>

</dd>
<dt id="extension">extension</dt>
<dd>

<p>Limit to only files with this extension. Requests for other files within <code>path</code> will result in a 404 response or be passed to the next application if <code>pass_through</code> is set.</p>

</dd>
<dt id="content_type">content_type</dt>
<dd>

<p>Specify the Content-Type header you want returned. If not specified, the content type will be guessed by <a href="https://metacpan.org/pod/Plack::MIME">Plack::MIME</a> based on the file extension with <code>default_type</code> as default.</p>

</dd>
<dt id="default_type">default_type</dt>
<dd>

<p>Specify the default Content-Type header. Defaults to to <code>text/html</code>.</p>

</dd>
<dt id="dir_index">dir_index</dt>
<dd>

<p>Which file to use as a directory index, defaults to <code>index.html</code>.</p>

</dd>
<dt id="vars">vars</dt>
<dd>

<p>Specify a hash reference with template variables or a code reference that gets a <a href="https://metacpan.org/pod/Plack::Request">Plack::Request</a> objects and returns a hash reference with template variables. By default only the QUERY_STRING params are provided as &#39;params&#39;. Templates variables specified by this option are added to existing template variables in the tt.vars environment variable.</p>

</dd>
<dt id="request_vars">request_vars</dt>
<dd>

<p>Specify a list of request variables from <a href="https://metacpan.org/pod/Plack::Request">Plack::Request</a> to be collected in a template variable &#39;request&#39;. For instance <code> [&#39;path&#39;,&#39;base&#39;] </code> gives you the template variables <code>request.path</code> and <code>request.base</code>. Setting this parameter to &#39;all&#39; gives you the original Plack::Request object, but this is unstable, bad practice because the object may change and your templates may damage the request object.</p>

<p>By default the request variables are decoded from byte strings to Unicode. You can change this with the configuration value <code>decode_request</code>.</p>

</dd>
<dt id="pass_through">pass_through</dt>
<dd>

<p>If this option is enabled, requests are passed back to the application, if the incoming request path matches with the <code>path</code> but the requested template file is not found. Disabled by default, so all matching requests result in a valid response with status code 200, 404, or 500.</p>

</dd>
<dt id="tt">tt</dt>
<dd>

<p>Directly set an instance of <a href="Template.html">Template</a> instead of creating a new one:</p>

<pre><code>  Plack::Middleware::TemplateToolkit-&gt;new( %tt_options );

  # is equivalent to:

  my $tt = Template-&gt;new( %tt_options );
  Plack::Middleware::TemplateToolkit-&gt;new( tt =&gt; $tt );</code></pre>

</dd>
<dt id="encode_response">encode_response</dt>
<dd>

<p>If your templates or template variables are Unicode strings, the output must be encoded, because PSGI expects the content body to be a byte stream. You can specify an encoding, such as <code>utf8</code> with this parameter, so the output is encoded to a byte string. The default setting is <code>utf8</code> which encodes to UTF-8 bytes. This default option is useful if your input contains non-ASCII characters, but it may lead to double encoded UTF-8 bytes, if you accidently mix strings with UTF-8 flag and without. To find such implicit encoding conversions, try <a href="https://metacpan.org/pod/encoding::warnings">encoding::warnings</a>.</p>

</dd>
<dt id="decode_request">decode_request</dt>
<dd>

<p>Similar to <code>encode_response</code>, this parameter decodes the input request from a byte string to an encoding of your choice. Set to <code>utf8</code> by default.</p>

<p>It is highly recommended to use <a href="https://metacpan.org/pod/Plack::Middleware::Lint">Plack::Middleware::Lint</a> and test your app with Unicode from several sources (templates, variables, parameters, ...).</p>

</dd>
<dt id="timer">timer</dt>
<dd>

<p>Time the processing and add <code>tt.start</code>, <code>tt.end</code>, and <code>tt.elapsed</code> to the environment.</p>

</dd>
<dt id="404-and-500"><a id="404"></a><a id="and-500"></a>404 and 500</dt>
<dd>

<p>Specifies an error template that is processed when a file was not found (404) or on server error (500). The template variables <code>error</code> with an error message, <code>path</code> with the request path, and <code>request</code> with the request objects are set for processing. If an error template count not be found and processed, another error with status code 500 is returned, possibly also as template.</p>

</dd>
</dl>

<h1 id="ENVIRONMENT">ENVIRONMENT</h1>

<p>This middleware inspects and/or manipulates the following variables from the PSGI environment:</p>

<dl>

<dt id="tt.vars"><a id="tt1"></a>tt.vars</dt>
<dd>

<p>Injected as template variables if defined. Set to the template variables.</p>

</dd>
<dt id="tt.path"><a id="tt2"></a>tt.path</dt>
<dd>

<p>Set to the template that was asked to process. This is equal to the local path (<code>path_info</code> in <a href="https://metacpan.org/pod/Plack::Request">Plack::Request</a>) if the request matched. If this variable is set <i>before</i> the middleware is called, it uses its value instead of path_info.</p>

</dd>
<dt id="tt.template"><a id="tt3"></a>tt.template</dt>
<dd>

<p>Set to the template that has actually been processed. If this variable is set <i>before</i> the middleware is called, the specified template is processed. In this all other settings (path, extensions, dir_index, and tt.path) are ignored.</p>

</dd>
</dl>

<p>You can view these variables with <a href="https://metacpan.org/pod/Plack::Middleware::Debug::TemplateToolkit">Plack::Middleware::Debug::TemplateToolkit</a>.</p>

<h1 id="METHODS">METHODS</h1>

<p>In addition to the call() method derived from <a href="https://metacpan.org/pod/Plack::Middleware">Plack::Middleware</a>, this class defines the following methods for internal use.</p>

<h2 id="process_template-(-$template,-$code,-\%vars-)"><a id="process_template"></a><a id="process_template----template---code---vars"></a>process_template ( $template, $code, \%vars )</h2>

<p>Calls the process() method of <a href="Template.html">Template</a> and returns the output in a PSGI response object on success. The first parameter indicates the input template&#39;s file name. The second parameter is the HTTP status code to return on success. A reference to a hash with template variables may be passed as third parameter. On failure this method returns an error message instead of a reference.</p>

<h2 id="process_error-(-$code,-$error,-$type,-$req-)-=-@_;"><a id="process_error"></a><a id="process_error----code---error---type---req------_"></a>process_error ( $code, $error, $type, $req ) = @_;</h2>

<p>Returns a PSGI response to be used as error message. Error templates are used if they have been specified and prepare_app has been called before. This method tries hard not to fail: undefined parameters are replaced by default values. In list context this returns a PSGI response and the actual template that has been used to create the error document.</p>

<h1 id="SEE-ALSO"><a id="SEE"></a>SEE ALSO</h1>

<p><a href="Plack.html">Plack</a>, <a href="Template.html">Template</a>, <a href="https://metacpan.org/pod/Plack::Middleware::Debug::TemplateToolkit">Plack::Middleware::Debug::TemplateToolkit</a></p>

<h1 id="AUTHORS">AUTHORS</h1>

<p>Leo Lapworth (started) and Jakob Voss (most of the work!)</p></div>

<div id="metacpan_install-instructions-dialog" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">Module Install Instructions</h4>
      </div>
      <div class="modal-body">
        <p>To install Plack::Middleware::TemplateToolkit, copy and paste the appropriate command in to your terminal.</p>
        <p><a href="https://metacpan.org/dist/App-cpanminus/view/bin/cpanm">cpanm</a></p>
        <pre><code>cpanm Plack::Middleware::TemplateToolkit</code></pre>
        <p><a href="https://metacpan.org/pod/CPAN">CPAN shell</a></p>
        <pre><code>perl -MCPAN -e shell
install Plack::Middleware::TemplateToolkit</code></pre>
        <p>For more information on module installation, please visit <a href="https://www.cpan.org/modules/INSTALL.html">the detailed CPAN module installation guide</a>.</p>
      </div>
      <div class="modal-footer">
        <a href="./Plack::Middleware::TemplateToolkit.html#" data-dismiss="modal" class="btn">Close</a>
      </div>
    </div>
  </div>
</div>
          </main>
          <div class="content-pagination">
          </div>
        </div>
        <footer class="footer">
          <div class="footer-container">
            <div class="footer-social">
              <div class="footer-link footer-logo">
                <a href="https://metacpan.org/">
                  <img src="https://metacpan.org/static/images/metacpan-logo.svg" alt="MetaCPAN" />
                </a>
              </div>
              <a class="footer-social-link" href="https://github.com/metacpan">
                <i class="fab fa-github-square"></i>
              </a>
              <a class="footer-social-link" href="https://fosstodon.org/@metacpan">
                <i class="fab fa-mastodon"></i>
              </a>
            </div>
            <div class="footer-links">
              <div class="footer-link">
                  <a href="https://metacpan.org/about">About</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/about/sponsors">Sponsor</a>
              </div>
              <div class="footer-link">
                  <a href="https://grep.metacpan.org">grep::cpan</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/recent">Recent</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/about/faq">FAQ</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/tools">Tools</a>
              </div>
              <div class="footer-link">
                  <a href="https://fastapi.metacpan.org/">API</a>
              </div>
              <div class="footer-link">
                  <a href="https://www.perl.org/">Perl.org</a>
              </div>
            </div>
            <div class="footer-sponsors">
              <a class="footer-sponsor-link" target="_blank" href="https://www.bytemark.co.uk/" rel="noopener">
                <img class="footer-sponsor-bytemark" src="https://metacpan.org/static/images/sponsors/bytemark_logo.svg" alt="Bytemark logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://www.liquidweb.com/" rel="noopener">
                <img class="footer-sponsor-liquidweb" src="https://metacpan.org/static/images/sponsors/liquidweb_logo.png" alt="liquidweb logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://deriv.com/careers/" rel="noopener">
                <img class="footer-sponsor-deriv" src="https://metacpan.org/static/images/sponsors/deriv.svg" alt="Deriv logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://geocode.xyz" rel="noopener">
                <img class="footer-sponsor-geocode" src="https://metacpan.org/static/images/sponsors/geocodelogo.svg" alt="Geocode logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://www.fastly.com/" rel="noopener">
                <img class="footer-sponsor-fastly" src="https://metacpan.org/static/images/sponsors/fastly_logo.svg" alt="Fastly logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://opencagedata.com" rel="noopener">
                <img class="footer-sponsor-opencage" src="https://metacpan.org/static/images/sponsors/open-cage.svg" alt="OpenCage logo">
              </a>
            </div>
          </div>
        </footer>
        <div class="modal fade" tabindex="-1" role="dialog" id="metacpan_keyboard-shortcuts">
          <div class="modal-dialog">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">Keyboard Shortcuts</h4>
              </div>
              <div class="modal-body row">
<div class="col-md-6">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>Global</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>s</kbd>
        </td>
        <td>Focus search bar</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>?</kbd>
        </td>
        <td>Bring up this help dialog</td>
      </tr>
    </tbody>
  </table>

  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>GitHub</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>p</kbd>
        </td>
        <td>Go to pull requests</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>i</kbd>
        </td>
        <td>go to github issues (only if github is preferred repository)</td>
      </tr>
    </tbody>
  </table>
</div>

<div class="col-md-6">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>POD</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>a</kbd>
        </td>
        <td>Go to author</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>c</kbd>
        </td>
        <td>Go to changes</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>i</kbd>
        </td>
        <td>Go to issues</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>d</kbd>
        </td>
        <td>Go to dist</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>r</kbd>
        </td>
        <td>Go to repository/SCM</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>s</kbd>
        </td>
        <td>Go to source</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>b</kbd>
        </td>
        <td>Go to file browse</td>
      </tr>

    </tbody>
  </table>
</div>

<div class="col-md-12">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>Search terms</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><em>module:</em> (e.g. <a href="https://metacpan.org/search?q=module%3APlugin">module:Plugin</a>)</td>
      </tr>
      <tr>
        <td><em>distribution:</em> (e.g. <a href="https://metacpan.org/search?q=distribution%3ADancer+auth">distribution:Dancer auth</a>)</td>
      </tr>
      <tr>
        <td><em>author:</em> (e.g. <a href="https://metacpan.org/search?q=author%3ASONGMU+Redis">author:SONGMU Redis</a>)</td>
      </tr>
      <tr>
        <td><em>version:</em> (e.g. <a href="https://metacpan.org/search?q=version%3A1.00">version:1.00</a>)</td>
      </tr>
    </tbody>
  </table>
</div>
              </div>
              <div class="modal-footer"></div>
            </div>
          </div>
        </div>
    </body>
</html>
